package com.lj.job.result;

import com.lj.job.entity.JobLog;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;

/**
 * <p>
 * 定时任务日志 分页结果
 * </p>
 *
 * @author luojing
 * @since 2025-03-20 15:26:16
 */
@Data
@Schema(description = "定时任务日志 分页结果")
public class JobLogPageResult {

    @Schema(description = "定时任务id ")
    private Long jobId;

    @Schema(description = "执行bean的名称 ")
    private String beanName;

    @Schema(description = "执行参数 ")
    private String params;

    @Schema(description = "是否成功 ")
    private Boolean succeed;

    @Schema(description = "错误信息 ")
    private String error;

    @Schema(description = "耗时 (单位: ms) ")
    private Integer times;

    private LocalDateTime createTime;

    public static JobLogPageResult of(JobLog entity) {
        if (entity == null) {
            return null;
        }
        JobLogPageResult result = new JobLogPageResult();
        result.setJobId(entity.getJobId());
        result.setBeanName(entity.getBeanName());
        result.setParams(entity.getParams());
        result.setSucceed(entity.getSucceed());
        result.setError(entity.getError());
        result.setTimes(entity.getTimes());
        result.setCreateTime(entity.getCreateTime());
        return result;
    }
}
